package com.hw.paltfrom.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.hw.paltfrom.pojo.HwCaseMain;
import com.hw.paltfrom.vo.StationCaseMainStatisticVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 李俊君
 * @since 2019-11-08
 */
@Component
public interface HwCaseMainMapper extends BaseMapper<HwCaseMain> {

    @Select("SELECT os.F_OverrunCode fOverrunCode,os.F_SimpleSpelling fSimpleSpelling,os.F_OverrunName fOverrunName,(SELECT COUNT(*) FROM HW_Case_Main cm WHERE os.F_OverrunCode = cm.F_OverrunCode AND cm.F_AJ_CrtStep <> '07') executingCases,(SELECT COUNT(*) FROM HW_Case_Main cm WHERE os.F_OverrunCode = cm.F_OverrunCode AND cm.F_AJ_CrtStep = '07' AND CONVERT(VARCHAR(20),cm.F_AJ_EndTime,120) BETWEEN '${startTime}' AND '${endTime}') finishedCases FROM dbo.HW_Base_OverrunStation AS os WHERE os.F_DeleteMark = 0 AND os.F_EnabledMark = 1 ORDER BY F_SortCode")
    List<StationCaseMainStatisticVO> queryStationCase(@Param("startTime")String startTime, @Param("endTime")String endTime);
    
    
//    select  F_CL_TruckNo, count(*)  FROM HW_Case_Main   WHERE  F_AJ_CrtStep = 07   GROUP BY F_CL_TruckNo
    @Select("select  F_CL_TruckNo, count(*) as num  FROM HW_Case_Main   WHERE  F_AJ_CrtStep = 07 and F_CL_CheckTime BETWEEN '${formatStartTime}' AND '${formatEndTime}'  GROUP BY F_CL_TruckNo")
    List<Map<String,Object>> queryStationGroup(@Param("formatStartTime")String formatStartTime, @Param("formatEndTime")String formatEndTime);
}
